import fetch from '@/utils/fetch'

/**
 * 获取初始化图片数据
 * @param {*} pagelist 分页的数据
 * 函数用来初始化素材图片的数据
 */
export function getPic (pagelist) {
  return fetch({
    url: 'api/jp-BIRM-UserProfile-ms' 
        + '/priFuncImg/page?pageNum='
        + pagelist.page
        + '&pageSize='
        + pagelist.pageSize,
    method: 'get'
  })
}

/**
 * 新增图片
 * @param {*} data 包含三个参数
 * storeId: 图片微服务存放的查询id
 * name：显示的名字
 * createUserId：创建者的id
 */
export function postAddPicture(data) {
  return fetch({
    url: 'api/jp-HCZZ-AdminWeb-app-ms/' 
        + 'source/img/add'
        + '?storeId='
        + data.storeId
        + '&name='
        + data.name
        + '&createUserId='
        + data.createUserId,
    method: 'get'
  })
}

/**
 * 修改图片素材
 */
export function updatePicture(data) {
  return fetch({
    url: 'api/jp-HCZZ-AdminWeb-app-ms/'
        +'source/img/update'
        +'?id='
        +data.id
        +'&storeId='
        +data.storeId
        +'&name='
        +data.name
        +'&updateUserId='
        +data.updateUserId,
     method: 'get'
  })
}

//删除图片
export function deletePic (data) {
  return fetch({
    url: 'api/jp-HCZZ-AdminWeb-app-ms/'
        +'source/img/delete',
    data: data,
    method: 'post'
  })
}

export function searchPic (data) {
  //搜索接口
  //http://172.17.99.30:10014/
  //api/jp-HCZZ-AdminWeb-app-ms/source/img/queryByName?name=%201&page=0&pageSize=%2018
  return fetch({
    url: 'api/jp-HCZZ-AdminWeb-app-ms/'
        +'source/img/queryByName?name='
        +data.name
        +'&page='
        +data.page
        +'&pageSize='
        +data.pageSize,
    method:'get',
  })
}

export function getAddPic () {
  return fetch({
    url: '/pic/defaultPic',
    method: 'get'
  })
}


export function editPic (result) {
  return fetch({
    // url: '/priFuncImg?id='+id+'&name='+name+'&updateUserId='+updateUserId+"&updateTime="+updateTime,
    url: '/priFuncImg?'+new Date().getTime(),
    method: 'put',
    data:result
  })
}


export function addPic(result){
  return fetch({
    url:'/priFuncImg',
    method:"post",
    data:result
    // header:{'content-type':"application/x-www-form-urlencoded;charset=UTF-8"},
  })
}